GD Function Reference

Course- C IN LINUX >

A full detailed set of documentation is maintained at: http://www.boutell.com/gd

GD contains a wealth of functionality for all kinds of drawing and many formats, as well as TrueType fonts and animated Gif images. A categorised list of functions follows:

Image creation, destruction, loading and saving:
  • gdImageCreate(int sx, int sy)
  • gdImageCreateFromJpeg(FILE *in)
  • gdImageCreateFromPng(FILE *in)
  • gdImageCreateFromGif(FILE *in)
  • gdImageCreateFromGd(FILE *in)
  • gdImageCreateFromWBMP(FILE *in)
  • gdImageDestroy(gdImagePt rim)
  • void gdImageJpeg(gdImagePt rim, FILE*out, int quality)
  • void gdImageGif(gdImagePt rim, FILE*out)
  • void gdImagePng(gdImagePtr im, FILE*out)
  • void gdImageWBMP(gdImagePtr im, int fg, FILE*out)
  • void gdImageGd(gdImagePtr im, FILE*out)
Drawing Functions:
  • void gdImageSetPixel(gdImagePtr im, int x, int y, int color)
  • void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
  • void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
  • void gdImagePolygon(gdImagePtr im, gdPoint Ptr point s, int point sTotal, int color)
  • void gdImageOpenPolygon(gdImagePtr im, gdPoint Ptr point s, int point sTotal, int color)
  • void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
  • void gdImageFilledPolygon(gdImagePtr im, gdPoint Ptr point s, int point sTotal, int color)
  • void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
  • void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
  • void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
  • void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color)
  • void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color)
  • void gdImageFill(gdImagePtr im, int x, int y, int color)
  • void gdImageSetAntiAliased(gdImagePtr im, int c)
  • void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c)
  • void gdImageSetBrush(gdImagePtr im, gdImagePtr brush)
  • void gdImageSetTile(gdImagePtr im, gdImagePtr tile)
  • void gdImageSetStyle(gdImagePtr im, int *style, int styleLength)
  • void gdImageSethickness(gdImagePtr im, int thickness)
  • void gdImageAlphaBlending(gdImagePtr im, int blending)
  • void gdImageSaveAlpha(gdImagePtr im, int saveFlag)
  • void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2)
  • void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
Query Functions:
  • int gdImageAlpha(gdImagePtr im, int color)(MACRO)
  • int gdImageGetPixel(gdImagePtr im, int x, int y)
  • int gdImageBoundsSafe(gdImagePtr im, int x, int y)
  • int gdImageGreen(gdImagePtr im, int color)(MACRO)
  • int gdImageRed(gdImagePtr im, int color)(MACRO)
  • int gdImageSX(gdImagePtr im)(MACRO)
  • int gdImageSY(gdImagePtr im)(MACRO)
  • int gdImageTrueColor(im)(MACRO)
Text-handling functions:
  • gdFontPtr gdFontGetSmall(void )
  • gdFontPtr gdFontGetLarge(void )
  • gdFontPtr gdFontGetMediumBold(void )
  • gdFontPtr gdFontGetGiant(void )
  • gdFontPtr gdFontGetTiny(void )
  • void gdImageChar(gdImagePtr im, gdFontPtr font, int x, int y, int c, int color)
  • void gdImageCharUp(gdImagePtr im, gdFontPtr font, int x, int y, int c, int color)
  • void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char*s, int color)
  • void gdImageString16(gdImagePtr im, gdFontPtr font, int x, int y, unsigned short *s, int color)
  • void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char*s, int color)
  • void gdImageStringUp16(gdImagePtr im, gdFontPtr font, int x, int y, unsigned short*s, int color)
  • char *gdImageStringFT(gdImagePtr im, int *brect, int fg, char *fontname, double
  • ptsize, double angle, int x, int y, char*string)
  • char *gdImageStringFTEx(gdImagePtr im, int *brect, int fg, char *fontname, double
  • ptsize, double angle, int x, int y, gdFTString ExtraPtr strex)
  • char *gdImageStringFTCircle(gdImagePtr im, int cx, int cy, double radius,
  • double textRadius, double illPortion, char*font, double point s,
  • char*top, char*bottom, int fgcolor)
  • char *gdImageStringTTF(gdImagePtr im, int *brect, int fg, char *fontname,
  • double ptsize, double angle, int x, int y, char *string)
Color-handling functions:
  • int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)
  • int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a)
  • int gdImageColorClosest(gdImagePtr im, int r, int g, int b)
  • int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a)
  • int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b)
  • int gdImageColorExact(gdImagePtr im, int r, int g, int b)
  • int gdImageColorResolve(gdImagePtr im, int r, int g, int b)
  • int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a)
  • int gdImageColorsTotal(gdImagePtr im)(MACRO)
  • int gdImageRed(gdImagePtr im, int c)(MACRO)
  • int gdImageGreen(gdImagePtr im, int c)(MACRO)
  • int gdImageBlue(gdImagePtr im, int c)(MACRO)
  • int gdImageGetInterlaced(gdImagePtr im)(MACRO)
  • int gdImageGetTransparent(gdImagePtr im)(MACRO)
  • void gdImageColorDeallocate(gdImagePtr im, int color)
  • void gdImageColorTransparent(gdImagePtr im, int color)
  • void gdTrueColor(int red, int green, int blue)(MACRO)
  • void gdTrueColorAlpha(int red, int green, int blue, int alpha)(MACRO)
Resizing functions:
  • void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
  • void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int destW, int destH, int srcW, int srcH)
  • void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, Int srcY, int destW, int destH, int srcW, int srcH)
  • void gdImageCopyRotated(gdImagePtr dst, gdImagePtr src, doubledstX, doubledstY, int srcX, int srcY, int srcW, int srcH, int angle)
  • void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
  • void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
  • void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src)
  • void gdImageSquareToCircle(gdImagePtr im, int radius)
  • void gdImageSharpen(gdImagePtr im, int pct)
Miscellaneous Functions:
  • int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
  • gdImageInterlace(gdImagePtr im, int int erlace)
  • gdFree(void *ptr)

In order to use a library like this you will need familiarity with the arguments which are oten data types deined within the library itself such as gdmagePtr which is a pointer to some kind of structure containing all the data for an image to be processed or stored. hese may all seem unusual but ater a while you will begin to get used to the syntax and on-line documentation and begin to see patterns in the complexity.